package editor;

import java.awt.Dimension;
import java.awt.Toolkit;

import org.jwalk.JWalker;

import editor.manager.MenuManager;
import editor.manager.SideBarManager;
import editor.manager.WorkSpaceManager;
import editor.project.Project;

/**
 * Acts as a register, which stores all the main components of the editor.
 * 
 * @author Mark Dessain
 */
public class Context 
{

	// Current Version Numbers
	private final static String jWalkVersion = "10.0";
	private final static String editorVersion = "1.1";

	// JWalk Classes
	private final static JWalker jWalker = new JWalker();

	// Screen Resolution
	private final static Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

	// Settings
	private final static EditorSettings settings = new EditorSettings();

	// The Frame consists of the following elements
	private final static MenuManager menuManager = new MenuManager();
	private final static SideBarManager sideBarManager = new SideBarManager();
	private final static WorkSpaceManager workSpaceManager = new WorkSpaceManager();

	// Main Editor Class
	private final static JWalkEditor jWalkEditor = new JWalkEditor();

	// Editor Properties
	private static Mode mode = Mode.CODING;
	private static Project mainProject = null;

	/**
	 * Switches the mode of the editor.
	 * @param mode the new mode 
	 */
	public static void switchMode(Mode mode) 
	{
		Context.mode = mode;

		// Sends down messages to each component informing them of updates which they need to make
		menuManager.switchMode(mode);
		sideBarManager.switchMode(mode);
		workSpaceManager.switchMode(mode);
	}

	/**
	 * @return the MenuManager
	 */
	public static MenuManager getMenuManager() 
	{
		return Context.menuManager;
	}
	
	/**
	 * @return the WorkSpaceManager
	 */
	public static WorkSpaceManager getWorkSpaceManager() 
	{
		return Context.workSpaceManager;
	}

	/**
	 * @return the SideBarManager
	 */
	public static SideBarManager getSideBarManager() 
	{
		return Context.sideBarManager;
	}

	/**
	 * @return the JWalkEditor frame
	 */
	public static JWalkEditor getJwalkEditor() 
	{
		return Context.jWalkEditor;
	}

	/**
	 * @return the Mode
	 */
	public static Mode getMode() 
	{
		return Context.mode;
	}

	/**
	 * @param mode the new Mode
	 */
	public static void setMode(Mode mode) 
	{
		Context.mode = mode;
	}

	/**
	 * @return the main Project
	 */
	public static Project getMainProject() 
	{
		return Context.mainProject;
	}

	/**
	 * @param mainProject the new main Project
	 */
	public static void setMainProject(Project mainProject) 
	{
		Context.mainProject = mainProject;
	}

	/**
	 * @return the EditorSettings
	 */
	public static EditorSettings getEditorSettings() 
	{
		return Context.settings;
	}

	/**
	 * @return the Dimensions of the screen
	 */
	public static Dimension getScreenDimensions() 
	{
		return Context.screenSize;
	}

	/**
	 * @return the JWalker
	 */
	public static JWalker getJwalker() 
	{
		return Context.jWalker;
	}

	/**
	 * @return the JWalk Version number
	 */
	public static String getJwalkVersion() 
	{
		return Context.jWalkVersion;
	}

	/**
	 * @return the Editor Version number
	 */
	public static String getEditorVersion() 
	{
		return Context.editorVersion;
	}

}
